define(['jquery', 'bootstrap', 'frontend', 'template', 'table'], function ($, undefined, Frontend, Template, Table) {

    var Controller = {
        balance_gpt4_logs: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/balance_gpt4_logs',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'num', title: "金额", },
                        { field: 'desc', title: "备注", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },

                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        balance_logs: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/balance_logs',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'num', title: "金额", },
                        { field: 'desc', title: "备注", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },

                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        balance_draw_logs: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/balance_draw_logs',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'num', title: "金额", },
                        { field: 'desc', title: "备注", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },

                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        vip_logs: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/vip_logs',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'vip_expire_time', title: "VIP过期时间", formatter: Table.api.formatter.datetime,},
                        { field: 'desc', title: "备注", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },

                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        msg_cosplay: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/msg_cosplay',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'channel', title: "AI渠道", formatter: Controller.api.formatter.channel},
                        { field: 'message', title: "发送消息", align: 'left', },
                        { field: 'response', title: "返回内容",  align: 'left',},
                        { field: 'total_tokens', title: "消耗力",  align: 'left',},
                        { field: 'user_ip', title: "用户IP", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },
                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        msg_write: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/msg_write',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'channel', title: "AI渠道", formatter: Controller.api.formatter.channel},
                        { field: 'message', title: "发送消息", align: 'left', },
                        { field: 'response', title: "返回内容",  align: 'left',},
                        { field: 'total_tokens', title: "消耗力",  align: 'left',},
                        { field: 'user_ip', title: "用户IP", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },
                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        msg_web: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/index/order/msg_web',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        { field: 'id', title: "ID", sortable: true },
                        { field: 'channel', title: "AI渠道", formatter: Controller.api.formatter.channel},
                        { field: 'message', title: "发送消息", align: 'left', },
                        { field: 'response', title: "返回内容",  align: 'left',},
                        { field: 'total_tokens', title: "消耗力",  align: 'left',},
                        { field: 'user_ip', title: "用户IP", },
                        { field: 'create_time', title: "创建时间", formatter: Table.api.formatter.datetime, sortable: true },
                    ]
                ],
                fixedColumns: true,
                fixedRightNumber: 1,
                showColumns: false,
                showToggle: false,
                showExport: false,
                commonSearch: false,
                search: false,
            });

        },
        api:{
            formatter:{
                channel: function(value, row, index) {
                    if(value=="wenxin"){
                        return "文心一言";
                    }
                    if(value=="wenxin4"){
                        return "文心一言4.0";
                    }
                    if(value=="hunyuan"){
                        return "腾讯混元";
                    }
                    if(value=="hunyuan4"){
                        return "腾讯混元4.0";
                    }
                    return value;
                },
            }
        },
        

    };
    return Controller;
});
